#set ($colspan = 1)
#foreach($attribute in $Rails.Entity.Attributes)
#if( ! $attribute.IsHidden && ! $attribute.IsSQLTextColumn && $attribute.Display)
#set ($colspan = $colspan + 1)
#end
#end
<%@ Page Language="C#" Inherits="Castle.MonoRail.Views.AspView.ViewAtDesignTime" %>
<%@ Import namespace="Neo.Framework"%>
<%@ import namespace="Castle.MonoRail.Framework" %>
<%@ Import namespace="Castle.MonoRail.Framework.Helpers"%>
<%@ import namespace="System.Collections.Generic" %>
<%@ import namespace="System.Collections" %>
<%@ import namespace="${Rails.Model.Namespace}.Models" %>
<%@ import namespace="${Rails.Model.Namespace}.Controllers.Database" %>
<%@ import namespace="${Rails.Model.Namespace}.Controllers.Helpers" %>
<%@ import namespace="${Rails.Model.Namespace}.Controllers.Resources" %>
#set($entity = $Neo.Entity)
<aspView:properties>
<% 
${Rails.Entity.ClassName}Surrogate ${Rails.Entity.ClassName.ToLower()};
IPaginatedPage ${Rails.Entity.ClassName.ToLower()}Items;
string sort;
string dir;
string dirnow;
Site CurrentSite;
AbstractBaseSmartDispatchController CurrentController; 
MenuHelper MenuHelper;
CustomHtmlHelper CustomHtmlHelper; 
${Rails.Entity.ClassName}Helper ${Rails.Entity.ClassName}Helper;
#set($noDups = "")              
#foreach($column in $entity.Attributes)
#set($rel = $entity.RelationshipForAttribute($column))
#if($rel && $rel.Direction.ToString() == "Child")
#if($noDups.Contains(" $rel.ForeignEntity.ClassName.ToLower()s ") == false)
IList ${rel.ForeignEntity.ClassName.ToLower()}s;
#set($noDups = "$noDups $rel.ForeignEntity.ClassName.ToLower()s ") 
#end
#end
#end
%>
</aspView:properties>
<component:MessagesComponent>
</component:MessagesComponent>
<% Hashtable dict = new Hashtable(); %>
<% if (Properties.ContainsKey("sort")) { %>
#if( $Rails.Entity.ToOneRelationships.Count > 0 )
<%= this.Helpers.Html.Form(siteRoot + "/${Rails.Entity.ClassName}/List.ashx", this.Helpers.Dict.CreateDict("method=get", "class=f-wrap-1") ) %>
<fieldset>
<h3><%= CommonResource.Filter %></h3>
<%= this.Helpers.Html.InputHidden( "sort", sort )  %>
<%= this.Helpers.Html.InputHidden( "dir", dirnow )  %>
#foreach($attribute in $Rails.Entity.Attributes)
#if($attribute.Display)
#if($Rails.Entity.RelationshipForAttribute($attribute) && $Rails.Entity.RelationshipForAttribute($attribute).Direction.ToString == "Child")
	<label for="${Rails.Entity.ClassName}.${attribute.DotNetName}"><b>#if($attribute.IsRequired)<span class="req">*</span>#end<%= ${Rails.Entity.ClassName}Resource.${attribute.DotNetName} %><%= CustomHtmlHelper.MakeHelpImage("${attribute.DotNetName}", ${Rails.Entity.ClassName}Resource.Help_${attribute.DotNetName}) %></b>
  	$HtmlHelpers.GenerateSelect($Rails.Entity, $attribute, 2)<br />
  </label>
  <% dict.Add("${Rails.Entity.ClassName}.${attribute.DotNetName}", ${Rails.Entity.ClassName.ToLower()}.${attribute.DotNetName}); %>
#end
#end
#end
	<div class="f-submit-wrap">
		<input type="submit" name="Submit" id="Submit" value="<%= CommonResource.Filter %>" class="f-submit" /><br />
	</div>
</fieldset> 
<%= this.Helpers.Html.EndForm() %>
#end
<% dict.Add("sort", sort); %>
<% dict.Add("dir", dir); %>
<% dict.Add("dirnow", dirnow); %>
<%= CustomHtmlHelper.PaginationControl(${Rails.Entity.ClassName.ToLower()}Items, null, dict )  %>
<% } %>
<%= MenuHelper.CreateNewLink(String.Format(CommonResource.Action_Create,  ${Rails.Entity.ClassName}Resource.${Rails.Entity.ClassName})) %>
<div style="overflow: scroll;">
<table class="tablewide">
	<thead>
		<tr>
			<th colspan="$colspan"><%= String.Format(CommonResource.List, ${Rails.Entity.ClassName}Resource.${Rails.Entity.ClassName}) %></th>
		</tr>
	</thead>
	<tbody>
  <tr>
<% if (Properties.ContainsKey("sort")) { %>
#foreach($attribute in $Rails.Entity.Attributes)
#if( ! $attribute.IsHidden && $attribute.Display)
#if( ! $attribute.IsSQLTextColumn)
    <th><%= ${Rails.Entity.ClassName}Helper.ListColumnSort("$HtmlHelpers.GetSortName($Rails.Entity, $attribute)", ${Rails.Entity.ClassName}Resource.${attribute.DotNetName}, dict ) %></th>
#end
#end
#end
<% } else { %>
#foreach($attribute in $Rails.Entity.Attributes)
#if( ! $attribute.IsHidden && $attribute.Display)
#if( ! $attribute.IsSQLTextColumn)
    <th><%=  ${Rails.Entity.ClassName}Resource.${attribute.DotNetName}  %></th>
#end
#end
#end
<% } %>
    <th><%= CommonResource.Action %></th>
  </tr>
<% 
foreach (${Rails.Entity.ClassName} ${Rails.Entity.ClassName.ToLower()} in ${Rails.Entity.ClassName.ToLower()}Items) {
  List<String> qstring = new List<String>();
%>
  <tr>
#foreach($attribute in $Rails.Entity.Attributes)
#if($attribute.IsPkColumn)
<% qstring.Add("${attribute.DotNetName}" + "=" + ${Rails.Entity.ClassName.ToLower()}.${attribute.DotNetName}); %>
#end
#if( ! $attribute.IsHidden && $attribute.Display)
#if( ! $attribute.IsSQLTextColumn)
    <td>$HtmlHelpers.GenerateControlReadOnly($Rails.Entity, $attribute)</td>
#end	
#end
#end
    <td><%= MenuHelper.CreateEditLink(MenuHelper.Join(qstring, "&amp;")) %>&nbsp;<%= MenuHelper.CreateDetailLink(MenuHelper.Join(qstring, "&amp;")) %></td>
  </tr>
<% } %>
</tbody>
</table>
</div>
<%= MenuHelper.CreateNewLink(String.Format(CommonResource.Action_Create,  ${Rails.Entity.ClassName}Resource.${Rails.Entity.ClassName})) %>
